<?php

namespace App\Http\Controllers;

use App\CodeResponse;
use App\Input\MiaoInput;
use App\Services\MiaoSha\MiaoServies;
use function DI\string;

class MiaoController extends BaseController
{
    public function addRedisGoods()
    {
        $input = MiaoInput::new();
        /**@var MiaoInput */
        $ret = MiaoServies::getInstance()->addRedisGoods($input);
        if (!$ret['code']) {
            return $this->fail(CodeResponse::FAIL, $ret["message"]);
        }
        return $this->success();
    }

    public function endMiao()
    {
        $mId = $this->verifyInteger("mid");
        $ret = MiaoServies::getInstance()->miaoEnd($mId);
        if (!$ret['code']){
            return $this->fail(CodeResponse::FAIL,$ret["message"]);
        }
        return $this->success();
    }

    public function AddMiaoOrder(){
        $uid = $this->verifyInteger("uid");
        $mid = $this->verifyInteger("mid");
        $ret = MiaoServies::getInstance()->miaoAddOrder($uid,$mid);
        if (!$ret["code"]){
            return $this->fail(CodeResponse::FAIL,$ret["message"]);
        }
        return $this->success();
    }
}
